package com.cqjtu.tto.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.cqjtu.tto.service.PermissionService;
import com.cqjtu.tto.vo.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author：monkey-L
 * @description:
 * @date: 19:07 2021/12/11
 */
@RestController
@Api(tags = "权限模块")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

//    @SaCheckRole("admin")
    @PostMapping("permissionAdd")
    @ApiOperation(value = "增加权限",notes = "根据权限名称增加权限")
    public Results permissionAdd(String permissionsName) {
        return permissionService.permissionAdd(permissionsName);
    }

//    @SaCheckRole("admin")
    @PostMapping("permissionDelete")
    @ApiOperation(value = "删除权限",notes = "根据权限名字删除权限")
    public Results permissionDelete(String permissionsName) {
        return permissionService.permissionDelete(permissionsName);
    }

//    @SaCheckRole("admin")
    @PostMapping("permissionUpdate")
    @ApiOperation(value = "更新权限")
    public Results permissionUpdate(String oldPermissionsName, String newPermissionsName) {
        return permissionService.permissionUpdate(oldPermissionsName,newPermissionsName);
    }

//    @SaCheckRole("admin")
    @PostMapping("permissionSelectOne")
    @ApiOperation(value = "查询权限",notes = "根据权限名字查询权限")
    public Results permissionSelectOne(String permissionsName) {
        return permissionService.permissionSelectOne(permissionsName);
    }

//    @SaCheckRole("admin")
    @ApiOperation(value = "查询所有权限")
    @PostMapping("permissionSelectList")
    public Results permissionSelectList() {
        return permissionService.permissionSelectList();
    }

}
